{% extends "base.html" %}
{% load i18n %}

{% block content %}
<div class="page-wrapper">
    <!--block content-->
    <div class="page-header d-print-none">
        <div class="container-xl">
            <div class="row g-2 align-items-center">
                <div class="col">
                    <div class="page-pretitle">
                        AppSettings
                    </div>
                    <h2 class="page-title">
                        {% trans "App Settings" %}
                    </h2>
                </div>
            </div>
        </div>
    </div>

    <!-- Page body -->
    <div class="page-body">
        <div class="container-xl">
            <div class="card">
                <div class="card-body">
                    <div class="col-lg-12">
                        {% for setting in appsettings %}
                            <form method="post" action="" role="form" aria-label="{{setting.name}} form">{% csrf_token %}
                                <div class="row mb-1">
                                    <label class="col-sm-3 col-form-label">{% trans setting.name %}</label>
                                    <div class="col-sm-6">
                                    {% if setting.choices %}
                                        <select class="form-select" name="{{ setting.key }}"  onchange="this.form.submit()" title="{% trans setting.description %}">
                                            {% for choice in setting.choices_as_list %}
                                                <option {% if setting.value == choice %} selected {% endif %} value={{ choice }}>{% trans choice %}</option>
                                            {% endfor %}
                                        </select>
                                    {% else %}
                                        <input class="form-control" name="{{ setting.key }}" value="{{ setting.value }}" title="{% trans setting.description %}"  onchange="this.form.submit()"/>
                                    {% endif%}
                                    </div>
                                </div>
                            </form>
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
